package com.huishi.handler.ws;

import com.huishi.constant.WSConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ws")
public class WSController {
    @Autowired
    private WebSocketServer webSocketServer;

    @GetMapping("/send")
    public void sendMsg() throws InterruptedException {
        int i = 1;
        while (true){
            Thread.sleep(1000);
            webSocketServer.sendMessage("收到消息:" + i,WSConstant.FILE_TOPIC);
            i++;
        }
    }

}
